package com.example.javabasic.thread.classtwo.future.demo2;
// 服务端
public class ServerThread extends Thread {
    //消息队列
    private final RequestQueue queue ;
    //服务端状态 ,用于退出
    private volatile boolean  flag = true;

    public ServerThread(RequestQueue queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while(flag){
            Request request = queue.getRequest();
            if(request == null){
                continue;
            }
            String value = request.getValue();
            System.out.println("Server--> "+value);
        }
    }

    public void close(){
        this.flag = false;
    }
}
